#include <iostream>
#include <string>
#include <stdio.h>
enum
{
    Socket_Err,
    Bind_Err,
};
void Usage(const std::string &s)
{
    std::cout << "warning: illegal usage!" << std::endl;
    std::cout << "please input as this: " << s.c_str() << "local_port" << std::endl;
}
std::string FuncDefault(std::string request)
{
    return request + " Are you ok?";
}
// 读取命令调用shell函数
std::string ExcuteCommand(std::string request)
{
    std::cout << "Get a request: " << request << std::endl;
    FILE *fp = popen(request.c_str(), "r");
    if (fp == nullptr)
    {
        return "unknown";
    }

    std::string response;
    char buffer[1024];
    while (1)
    {
        char *s = fgets(buffer, sizeof(buffer), fp);
        if (s == nullptr)
        {
            break;
        }
        else
        {
            response += buffer;
        }
    }
    pclose(fp);
    return response;    // 2:237
}